package example.hellosecurity.mapper;


import example.hellosecurity.entity.User;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper {

    /*
    * 根据用户名查询
    * */
    User findByUsername(String username);

//    根据用户主键，查询角色名称 tb_role
    @Select("SELECT role_name FROM tb_role JOIN tb_user_role ON tb_role.id=tb_user_role.user_id  WHERE tb_user_role.user_id=#{id}")
    List<String> selectRoleByUserId(Integer id);


    /*
    * 根据用户主键查询资源描述
    * */

    @Select("SELECT res FROM tb_resource JOIN tb_role_res ON tb_resource.id=tb_role_res.role_id JOIN tb_user_role ON tb_role_res.role_id=tb_user_role.user_id  WHERE user_id=#{id}")
    List<String> selectByUserId(Integer id);


}
